//
//  ForgetPwdOneViewController.m
//  parent
//
//  Created by 闫珍 on 15/9/29.
//  Copyright © 2015年 ci123. All rights reserved.
//

#import "ForgetPwdOneViewController.h"
#import "AFAppClient.h"
#import "Tool.h"
#import "ForgetPwdTwoViewController.h"

@interface ForgetPwdOneViewController ()
@property (weak, nonatomic) IBOutlet UITextField *phone;

@end

@implementation ForgetPwdOneViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.navigationItem.title = @"忘记密码";
    [self CustomBackButton];
}


- (IBAction)goTwo:(id)sender {
    NSString *txt = self.phone.text;
    if([txt isEqualToString:@""]){
        [self showHudComplete:@"手机号码不能为空" success:NO];
    }else if(![Tool isMobileNumber:txt]){
        [self showHudComplete:@"请输入正确手机号码" success:NO];
    }else{
        
        NSString *sms_register_url = [NSString stringWithFormat:@"%@%@",SERVER_URL_NEW,kSMSRegister];
        NSDictionary *param = @{@"type":@(2),@"phone_num":txt};
        [self showHud:@"正在发送请求" isDim:YES];
        [[AFAppClient sharedManager]getWithURL:sms_register_url withParameters:param success:^(NSDictionary *responseObject) {
            [self hideHud2];
            NSUInteger code = [Tool defaultIntFromDic:responseObject withKey:@"code"];
            if(code>0){
                NSString *txt = self.phone.text;
                ForgetPwdTwoViewController *two = [[ForgetPwdTwoViewController alloc]init];
                two.phone = txt;
                [self.navigationController pushViewController:two animated:YES];
            }else{
               [self showHudComplete:@"网络不给力，请检查网络" success:NO];
            }
        } failure:^(NSError *error) {
            [self showHudComplete:@"网络不给力，请检查网络" success:NO];
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
